<!--
 * @FilePath     : /study_code/vue3.x/reactive.html
 * @Description  : reactive() 定义&修改 响应式值
 * @Date         : 2025-05-10 16:11:17
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-05-10 16:13:30
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="./common/style.css" />
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script src="./common/common.js"></script>
  </head>
  <body>
    <div id="app">
      <p>信息{{ message }}</p>
      <p>长度{{ state.count }}</p>

      <hr />

      <button @click="state.count++">模板中 内联修改</button>
      <button @click="addCount">js 方法中修改</button>
    </div>

    <!-- is| v-for| v-if, v-else-if, v-show, v-cloak| v-pre, v-once| id| ref,key| v-model| (html原生属性)|(动态属性)| v-on| v-html, v-text -->

    <script>
      /*
      // 自定义组件
      const myComponent = {
        data: function () {
          return {}
        },
        props: [],
        template: ``,
        methods: {},
      }
      */

      // el| name, parent| functional| delimiters, comments| components, directives, filters| extends, mixins| inheritAttes, model, props/propsData| data, computed| watch| 生命周期钩子(beforeCreate, created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, destroyed)| methods| template/render, renderError

      const { createApp, ref, reactive } = Vue

      createApp({
        setup() {
          const message = ref('Hello vue!')
          const state = reactive({ count: 0 })

          const addCount = () => {
            console.log('方法内修改 reactive')
            state.count++
          }

          return {
            message,
            state,
            addCount,
          }
        },
      }).mount('#app')
    </script>
  </body>
</html>
